package com.sysd.exception;

import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.Optional;

/**
 * @description: 基本异常抽象类
 * @author: bsh
 * @date: 2025/5/30 10:51
 */
@Data
public abstract class AbstractException extends RuntimeException {
    private int code;
    private String msg;

    public AbstractException(int code, String msg, Throwable cause) {
        super(msg, cause);
        this.code = code;
        this.msg = Optional.ofNullable(StringUtils.hasLength(msg) ? msg : null).orElse(cause.getMessage());
    }
}
